package general

import (
	"gitee.com/huanminabc/go-utils/code_analysis"
	"go-CodeAnalysis/container"
)

// IDENTIFIER 转 CONSTANT
func IdentifierToConstant(tokens []code_analysis.Token) {
	for i := 0; i < len(tokens); i++ {
		if tokens[i].Type == code_analysis.IDENTIFIER {
			//判断是否是全局变量
			if container.IsGlobalVariable(tokens[i].Value) {
				tokens[i].Type = code_analysis.CONSTANT
				tokens[i].Value = container.GetGlobalVariable(tokens[i].Value)
			}
		}
	}
}
